package com.symbio.ishenapi.doctor.controller;

import com.symbio.ishenapi.common.bean.LoginUser;
import com.symbio.ishenapi.common.controller.BaseController;
import com.symbio.ishenapi.doctor.model.TmGroupNotice;
import io.jboot.web.controller.annotation.RequestMapping;

/**
 * @Author: chen
 * @Description:群公告控制层
 * @Date: Created in 18:18 2018/12/3
 * @Modified By:
 */
@RequestMapping("/TmGroupNotice")
public class TmGroupNoticeController extends BaseController{

    /** POST
     * @Author: chen
     * @Description:群公告保存
     * @Date: 18:19 2018/12/3
     * @param: [
     *              {
     *                  "groupId":"群id",
     *                  "content":"公告内容"
     *              }
     *          ]
     * @return: void
     */
    public void save(){
        try {
            TmGroupNotice notice = (TmGroupNotice)getReqBodyObject(TmGroupNotice.class);
            LoginUser loginUser = getLoginUser();
            TmGroupNotice.dao.saveGroupNotice(notice,loginUser);
            renderJsonError(50001,"群公告保存");
        }catch (Exception e){
            e.printStackTrace();
            renderJsonError(50002,"群公告保存");
        }
    }

    /** GET
     * @Author: chen
     * @Description:获取群内最新的公告信息
     * @Date: 18:40 2018/12/3
     * @param: [
     *              groupId     ---群id
     *          ]
     * @return: void
     */
    public void findGroupNoticeNewest(){
        try {
            String groupId = getPara("groupId");
            TmGroupNotice tmGroupNotice = TmGroupNotice.dao.findGroupNoticeNewest(groupId);
            renderJsonRet(tmGroupNotice);
        }catch (Exception e){
            e.printStackTrace();
            renderJsonError(50002,"群内最新公告查询");
        }
    }
}
